package com.yugu.park.system.controller;

import com.github.pagehelper.PageInfo;
import com.yugu.park.system.entity.SysLoginLogEntity;
import com.yugu.park.system.service.SysLoginLogService;
import com.yugu.util.ResponseUtil;
import com.yugu.util.SearchPage;
import com.yugu.util.SysQueryParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 登陆日志表
 *
 * @author guxf
 * @email sjzyug@163.com
 * @date 2024-01-26 10:30:29
 */
@Api(tags = {"管理端-登陆日志"})
@RestController
@RequestMapping("system/sysloginlog")
public class SysLoginLogController {
    @Autowired
    private SysLoginLogService service;

    /**
     * 列表
     */

    @ApiOperation(value="分页查询", notes="分页查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public ResponseUtil.Result<PageInfo<SysLoginLogEntity>> page (@RequestBody SearchPage<SysQueryParam> search){
        PageInfo<SysLoginLogEntity> page = service.page(search);
        return ResponseUtil.addSuccess(page);
    }
	@ApiOperation(value="查看详情", notes="查看详情")
    @GetMapping("/{id}")
    public ResponseUtil.Result<SysLoginLogEntity> info(@PathVariable("id") String id){
		SysLoginLogEntity sysLoginLog = service.getById(id);
        return ResponseUtil.addSuccess(sysLoginLog);
    }
    @ApiOperation(value="新增或修改", notes="新增或修改")
    @RequestMapping(value="/addOrUpdate", method= RequestMethod.POST)
    public ResponseUtil.Result<Boolean> addOrUpdate(@RequestBody SysLoginLogEntity sysLoginLog){
		service.addOrUpdate(sysLoginLog);
        return ResponseUtil.addSuccess(true);
    }
    @ApiOperation(value="批量删除", notes="批量删除")
    @RequestMapping(value="/{id}", method = RequestMethod.DELETE)
    public ResponseUtil.Result<Boolean> delete(@PathVariable("id") String id){
    	service.removeByIds(Arrays.asList(id.split(",")));
        return ResponseUtil.addSuccess(true);
    }

}
